package com.pkk.cloud.support.oauth2.store.serial;

import org.springframework.security.oauth2.provider.token.store.redis.StandardStringSerializationStrategy;

/**
 * @description: redis对象序列化工具
 * @author: peikunkun
 * @create: 2018-09-07 09:02
 **/
public class RedisSerializationStrategy extends StandardStringSerializationStrategy {

    private static final JsonSerializationRedisSerializer OBJECT_SERIALIZER = new JsonSerializationRedisSerializer();


    @Override
    protected <T> T deserializeInternal(byte[] bytes, Class<T> clazz) {
        return (T) OBJECT_SERIALIZER.deserialize(bytes);
    }

    @Override
    protected byte[] serializeInternal(Object object) {
        return OBJECT_SERIALIZER.serialize(object);
    }

}
